package com.sanqi.work.service.impl;

import java.util.List;
import com.sanqi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sanqi.work.mapper.WorkUserAccountMapper;
import com.sanqi.work.domain.WorkUserAccount;
import com.sanqi.work.service.IWorkUserAccountService;

import cn.hutool.core.collection.CollUtil;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 用户账号Service业务层处理
 * 
 * @author duany
 * @date 2025-10-09
 */
@Service
public class WorkUserAccountServiceImpl extends ServiceImpl<WorkUserAccountMapper, WorkUserAccount> implements IWorkUserAccountService 
{
    @Autowired
    private WorkUserAccountMapper workUserAccountMapper;

    /**
     * 查询用户账号
     * 
     * @param id 用户账号主键
     * @return 用户账号
     */
    @Override
    public WorkUserAccount selectWorkUserAccountById(String id)
    {
        return workUserAccountMapper.selectWorkUserAccountById(id);
    }

    /**
     * 查询用户账号列表
     * 
     * @param workUserAccount 用户账号
     * @return 用户账号
     */
    @Override
    public List<WorkUserAccount> selectWorkUserAccountList(WorkUserAccount workUserAccount)
    {
        return workUserAccountMapper.selectWorkUserAccountList(workUserAccount);
    }

    /**
     * 新增用户账号
     * 
     * @param workUserAccount 用户账号
     * @return 结果
     */
    @Override
    public int insertWorkUserAccount(WorkUserAccount workUserAccount)
    {
        return save(workUserAccount) ? 1 : 0;
    }

    /**
     * 修改用户账号
     * 
     * @param workUserAccount 用户账号
     * @return 结果
     */
    @Override
    public int updateWorkUserAccount(WorkUserAccount workUserAccount)
    {
        return updateById(workUserAccount) ? 1 : 0;
    }

    /**
     * 批量删除用户账号
     * 
     * @param ids 需要删除的用户账号主键
     * @return 结果
     */
    @Override
    public int deleteWorkUserAccountByIds(String[] ids)
    {
        return workUserAccountMapper.deleteWorkUserAccountByIds(ids);
    }

    /**
     * 删除用户账号信息
     * 
     * @param id 用户账号主键
     * @return 结果
     */
    @Override
    public int deleteWorkUserAccountById(String id)
    {
        return workUserAccountMapper.deleteWorkUserAccountById(id);
    }

    @Override
    public List<WorkUserAccount> queryByUserIds(List<String> userIdList) {
        return this.lambdaQuery().in(WorkUserAccount::getUserId, userIdList).list();
    }

    @Override
    public WorkUserAccount queryAccountByUserId(String userId) {
        List<WorkUserAccount> list = this.lambdaQuery().eq(WorkUserAccount::getUserId, userId).list();
        return CollUtil.isEmpty(list) ? null : list.get(0);
    }
}
